package cn.powertime.evaluation.web.controller;

import cn.powertime.evaluation.entity.CpsQuestionBank;
import cn.powertime.evaluation.facade.CpsQuestionBankFacade;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 题库表 前端控制器
 * </p>
 *
 * @author Yang Xin
 * @since 2019-09-25
 */
@RestController
@RequestMapping("/web/cpsQuestionBank")
@Api(value = "/web/cpsQuestionBank", tags = "题库接口", produces = MediaType.ALL_VALUE)
@Validated
public class CpsQuestionBankController extends BaseController {

    @Autowired
    private CpsQuestionBankFacade cpsQuestionBankFacade;

    @ApiOperation(value = "题库列表")
    @GetMapping(value = "/list")
    @ApiImplicitParam(name = "type", value = "题库类型，1:课后作业，2：课程刷题，3真题模拟，4：测评练习，5：自查工具", required = true, dataType = "Integer")
    public Object listAll(@NotNull(message = "题库类型不能为空") @Max(value = 5, message = "题库类型最大值为5") @Min(value = 1, message = "题库类型最小值为1") @RequestParam(defaultValue = "1") Integer type) {
        List<CpsQuestionBank> list = this.cpsQuestionBankFacade.listAll(type);
        return success(list);
    }

}
